<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="box">
      <button v-on:click="sub()"  v-bind:disabled="subDisabled">-</button>
      {{result}}
      <button v-on:click="add()"  v-bind:disabled="addDisabled">+</button>
    </div>

    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: "#box",
        data: {
          result:0,
          addDisabled:false,
          subDisabled:false
        },
        methods: {
          add:function(){
            this.result++;
            this.subDisabled=false
            if(this.result>=5){
              this.addDisabled=true;
            }
          },
          sub:function(){
            this.result--;
            this.addDisabled=false;
            if(this.result<=0){
              this.subDisabled=true;
            }
          }
        },
      });
      
    </script>
  </body>
</html>
